package me.liekkas.notify.email;

import me.liekkas.notify.sms.BizTypeEnum;

import java.util.Map;

public abstract class AbstractEmailSender implements IMailSend {

    protected Map<BizTypeEnum, IEmailTemplate> templateMap;

    @Override
    public MailResponse sendEmail(MailRequest request) {
        // 准备参数
        init();
        // 发送
        MailResponse response = doSend(request);
        // 记录日志
        log(request, response);
        return response;
    }

    protected abstract void init();

    protected abstract MailResponse doSend(MailRequest request);

    protected abstract void log(MailRequest request, MailResponse response);

    public Map<BizTypeEnum, IEmailTemplate> getTemplateMap() {
        return templateMap;
    }
}
